package com.gexiaobao.pigeon.ui.fragment.mine.banking

import android.os.Bundle
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.BaseFragment
import com.gexiaobao.pigeon.app.ext.initClose
import com.gexiaobao.pigeon.app.util.RxToast
import com.gexiaobao.pigeon.databinding.FragmentTransferDetailBinding
import com.gexiaobao.pigeon.viewmodel.MineBankingViewModel
import me.hgj.jetpackmvvm.ext.nav
import me.hgj.jetpackmvvm.ext.parseState

/**
 * @Author      : hxw
 * @Date        : 2023/5/31 19:46
 * @Describe    : 订单详情
 */
class FragmentTransferDetail : BaseFragment<MineBankingViewModel, FragmentTransferDetailBinding>() {

    private var mOrderId: Int = -1

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.includeBar.toolbar.initClose("订单详情") {
            nav().navigateUp()
        }
        mOrderId = requireArguments().getInt("orderId")
    }

    override fun lazyLoadData() {
        super.lazyLoadData()
        showLoading(getString(R.string.loading))
        mViewModel.getOrderDetail(mOrderId)
    }

    override fun createObserver() {
        super.createObserver()
        mViewModel.orderDetailResult.observe(viewLifecycleOwner) { resultState ->
            parseState(resultState, {
                mDatabind.data = it
            }, {
                RxToast.showToast(it.msg)
            })
        }
    }
}